import { defHttp } from '/@/utils/http/axios';
import { OrgSearchModel, OrgVOModel } from './model/orgModel';
import { BasicDelModel, BasicDetailModel } from '../model/baseModel';

enum Api {
  BaseApi = '/sys/org',
}

/**
 * @description: 获取组织机构树
 * @author xuyong
 * @date 2023-10-20 16:06:52
 */
export const getOrgTreeApi = (data?: OrgSearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/tree', data });
};

/**
 * @description: 获取组织机构的详细信息
 * @author xuyong
 * @date 2023-10-20 16:06:52
 */
export const getOrgDetailApi = (id: string) => {
  const data: BasicDetailModel = {
    id: id
  };
  return defHttp.post({ url: Api.BaseApi + '/detail', data });
};

/**
 * @description: 新增组织机构
 * @author xuyong
 * @date 2023-10-20 16:06:52
 */
export const saveOrgApi = (data: OrgVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/add', data });
};

/**
 * @description: 修改组织机构
 * @author xuyong
 * @date 2023-10-20 16:06:52
 */
export const updateOrgApi = (data: OrgVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/edit', data });
};

/**
 * @description: 删除组织机构
 * @author xuyong
 * @date 2023-10-20 16:06:52
 */
export const delOrgApi = (ids: string[]) => {
  const data: BasicDelModel = {
    ids: ids
  }
  return defHttp.post({ url: Api.BaseApi + '/delete', data });
};
